{if empty($_W['isajax'])}
{template 'common/top'}
{/if}
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <div class="base_topBar ">
        <div class="base_explain">
            <span id="toolbar_title">卡片知识</span>
            <div class="warn_info_box clearfix">
            </div>
        </div>
        <div class="base_topBar_right">
            <div class="operate_items clearfix">
                <div class="user_feedBack operate_item">
                    <a href="#" class="userFeedbackClick">
                        用户反馈
                    </a>
                </div>
            </div>
        </div>
    </div>
    <!-- Main content -->
    <section class="content">
        <!-- /.box-header -->
        <div class="box-header">
            <form action="" method="get"  class="form-horizontal">
                <input type="hidden" name="c" value="{php echo $_GPC['c']}"/>
                <input type="hidden" name="a" value="{php echo $_GPC['a']}"/>
                <input type="hidden" name="m" value="{php echo $_GPC['m']}"/>
                <input type="hidden" name="do" value="{php echo $_GPC['do']}"/>
                <input type="hidden" name="act" value="{php echo $_GPC['act']}"/>
                <div class="box-body">
                    <div class="form-group col-md-3">
                        <label class="col-sm-3 control-label">分类名称</label>
                        <div class="col-sm-9">
                            <select name="category_id" id="" class="form-control">
                                <option value="0">请选择</option>
                                {loop $categoryArr $item}
                                <option value="{$item['id']}" {if $item['id']==$_GPC['category_id']}selected{/if}>{$item['name']}</option>
                                {/loop}
                            </select>
                            <span class="help-block"></span>
                        </div>
                    </div>
                    <div class="form-group col-md-4">
                        <label class="col-sm-3 control-label">状态</label>
                        <div class="col-sm-9">
                            <select name="status"  class="form-control">
                                <option value="" {if $_GPC['status'] === ""}selected{/if}>全部</option>
                                <option value="1" {if $_GPC['status'] == 1}selected{/if}>显示</option>
                                <option value="0" {if $_GPC['status'] == "0"}selected{/if}>隐藏</option>
                            </select>
                            <span class="help-block"></span>
                        </div>
                    </div>
                    <div class="form-group col-md-4">
                        <label class="col-sm-3 control-label">标题</label>
                        <div class="col-sm-9">
                            <input type="text" name="name" placeholder="" value="{$_GPC['name']}" class="form-control"/>
                            <span class="help-block"></span>
                        </div>
                    </div>
                    <div class="col-md-1">
                        <input type="hidden" name="token" value="{$_W['token']}" />
                        <button type="submit" class="waves-effect waves-light btnMid btnBlue completeBtn">搜索</button>
                    </div>
                </div>

                <!-- /.box-body -->
            </form>
        </div>
        <!-- /.box-header -->
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header with-border">
                        <a href="{php echo $this->createWebUrl('tips',array('act'=>'edit'))}" class="waves-effect waves-light btnMid btnBlue completeBtn">新增知识</a>
                        <a data-href="{php echo $this->createWebUrl('tips',array('act'=>'mutdelete'))}" href="javascript:;" class="waves-effect waves-light btnMid btnRed completeBtn mutdelete">删除选中</a>
                    </div>
                    <!-- /.box-header -->
                    <div class="box-body">
                        <table id="example2" class="table table-hover">
                            <thead>
                            <tr>
                                <th class='col-md-1 hidden-xs hidden-sm'>
                                    <input type="checkbox" id="checkall"/>
                                </th>
                                <th class='col-md-1 hidden-xs hidden-sm'>序号</th>
                                <th class='col-md-1 hidden-xs hidden-sm'>排序</th>
                                <th class='col-md-1 hidden-xs hidden-sm'>分类名称</th>
                                <th class='col-md-4 hidden-xs hidden-sm'>标题</th>
                                <th class='col-md-1 hidden-xs hidden-sm'>收藏数</th>
                                <th class='col-md-1 hidden-xs hidden-sm'>点赞数</th>
                                <th class='col-md-1 hidden-xs hidden-sm'>状态</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {loop $list['list'] $li}
                            <tr>
                                <td><input type="checkbox" name="ids[]" value="{$li['id']}"/></td>
                                <td>{$li['id']}</td>
                                <td>{$li['sort']}</td>
                                <td>{$li['category_name']}</td>
                                <td>{$li['title']}</td>
                                <td>{$li['receive_count']}</td>
                                <td>{$li['praise_count']}</td>
                                <td>{$li['status']}</td>
                                <td>
                                    <a href="{php echo $this->createWebUrl('tips',array('act'=>'edit','id'=>$li['id']))}" >编辑</a>
                                    <a href="javascript:void(0);" style="cursor: default;">|</a>
                                    <a href="{php echo $this->createWebUrl('tips',array('act'=>'delete','id'=>$li['id']))}" onclick="return window.confirm('您确定要删除吗？');">删除</a>
                                </td>
                            </tr>
                            {/loop}
                            </tbody>
                        </table>
                    </div>
                    <div class="box-footer">
                        {php echo $list['pager']}
                    </div>
                    <!-- /.box-body -->
                </div>
                <!-- /.box -->
            </div>
        </div>
        <!-- /.row -->
    </section>
    <!-- /.content -->
</div>
</div>
<!-- ./wrapper -->

{if empty($_W['isajax'])}
{template 'common/foot'}
<script type="text/javascript">
    $('.mutdelete').click(function(){
        var url = $(this).data('href');
        var ids = [];
        var idss = [];
        $('input:checkbox[name="ids[]"]').each(function() {
            var _that = $(this)[0];
            if(_that.checked){
                ids = ids.concat($(this).val());
            }else{
                idss = idss.concat($(this).val());
            }
        });
        console.log(ids);
        if(confirm("您确定要删除么？")){
            $.post(url,{ids:ids},function(data){
                util.message("删除成功","{php echo $_W['siteurl']}",'success');
            },'json');
        }
    });
    $('.unmutdelete').click(function(){
        var ids = [];
        var idss = [];
        $('input:checkbox[name="ids[]"]').each(function() {
            var _that = $(this)[0];
            if(_that.checked){
                ids = ids.concat($(this).val());
            }else{
                idss = idss.concat($(this).val());
            }
        });
        console.log(idss);
        if(confirm("您确定要删除么？")){
            $.post(url,{ids:idss},function(data){
                util.message("删除成功","{php echo $_W['siteurl']}",'success');
            },'json');
        }
    })
    $("#checkall").click(function(){
        console.log('checkall');
        $('input[name="ids[]"').each(function(){
            var _that = $(this)[0];
            if(_that.checked){
                _that.checked = false;
            }else{
                _that.checked = true;
            }
        });
    });
</script>
{/if}